package com.zrrd.yunchmall.repository;

import com.zrrd.yunchmall.entity.TProduct;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author yekong
 */
//自定义一个GPI的接口，继承ElasticsearchRepository<实体类泛型，id泛型>
@Repository
@SuppressWarnings("all")
public interface TProductRepository extends ElasticsearchRepository<TProduct, Integer> {
    //根据商品名称进行查找, 接口定义规范，ElasticsearchRepository会自动生成响应的代码
    List<TProduct> findByPname(String pname);
    List<TProduct> findByPprice(double price);
    //同时根据名称，价格查找
    List<TProduct> findByPnameAndPprice(String name, double price);
    List<TProduct> findByPnameOrPprice(String name, double price);
    //范围查询
    List<TProduct> findByPpriceBetween(double p2, double p1);
    List<TProduct> findByPpriceLessThan(double p1);//findByPpriceBefore
    List<TProduct> findByPpriceGreaterThan(double p1);//findByPpriceAfter

    //字符串模糊查询的方法
    List<TProduct> findByPnameLike(String pname);
    List<TProduct> findByPnameStartingWith(String keyword);


}
